﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Algobox.JuicyLib.TimeSeries
{
    public class BaseTimeSeriesRecord
    {
        protected DateTime recordTime = DateTime.Now;

        public DateTime RecordTime
        {
            get { return recordTime; }
            set { recordTime = value; }
        }

        protected double recordValue;

        public double RecordValue
        {
            get { return recordValue; }
            set { recordValue = value; }
        }
        

        bool isGapFill = false;
        /// <summary>
        /// Indicates whether this record has no data
        /// </summary>
        public bool IsGapFill
        {
            get { return isGapFill; }
            set { isGapFill = value; }
        }


        public BaseTimeSeriesRecord()
        {
        }

        public BaseTimeSeriesRecord(double data)
        {
            recordValue = data;
        }

        public BaseTimeSeriesRecord(double data,DateTime now)
        {
            recordValue = data;
            recordTime = now;
        }

        /// <summary>
        /// override to implement different coping of fields
        /// </summary>
        /// <returns></returns>
        public virtual BaseTimeSeriesRecord CreateNewCopy()
        {
            return new BaseTimeSeriesRecord(recordValue, recordTime);  
        }

        public static bool operator > (BaseTimeSeriesRecord ts, DateTime time)
        {
            return ts.recordTime > time;
        }

        public static bool operator < (BaseTimeSeriesRecord ts, DateTime time)
        {
            return ts.recordTime < time;
        }

        public override bool Equals(object obj)
        {
            BaseTimeSeriesRecord tsr = ( BaseTimeSeriesRecord)obj;
            return (this.recordTime == tsr.recordTime);
        }

        public override int GetHashCode()
        {
            return this.recordTime.GetHashCode();
        }

        
    }
}
